<?php
// +----------------------------------------------------------------------
// | ThinkPHP [ WE CAN DO IT JUST THINK ]
// +----------------------------------------------------------------------
// | Copyright (c) 2006-2019 http://thinkphp.cn All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: liu21st <liu21st@gmail.com>
// +----------------------------------------------------------------------

// [ 应用入口文件 ]
namespace think;

// 设置时区为亚洲/上海
date_default_timezone_set('Asia/Shanghai');

header("Access-Control-Allow-Origin: *");
header("Access-Control-Allow-Credentials:true");
header("Access-Control-Allow-Methods:GET, POST, PUT, DELETE, OPTIONS");
header("Access-Control-Allow-Headers:Authorization, Content-Type, X-Requested-With, X-Token,x-api-key,think-lang,x-goaffpro-affinfo,X-Real-IP,X-Real-IP2,X-Forwarded-For,REMOTE_ADDR");

if ($_SERVER['REQUEST_METHOD'] === 'OPTIONS') {
    // 设置状态码为204 No Content
    http_response_code(204);
    // 发送CORS头
    header('Access-Control-Max-Age: 1728000'); // 可选，用于指定本次预检请求的有效期
    exit(); // 结束请求，不执行后续操作
}


require __DIR__ . '/../vendor/autoload.php';

// 执行HTTP应用并响应
$http = (new App())->http;

$response = $http->run();

$response->send();

$http->end($response);
